package com.zx.util;

import java.sql.*;

public class UserUtils {


    static String driver = "com.mysql.cj.jdbc.Driver";
    static String username = "root";
    static String password = "123456";
    static String url = "jdbc:mysql://localhost:3306/zuoye1?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai";

    public static Connection getConn() {
        Connection conn = null;
        try{
            Class.forName(driver);
            conn = DriverManager.getConnection(url, username, password);
        }catch (Exception e) {
            e.printStackTrace();
        }
        return conn;
    }

    public static void closeConn(Connection conn, Statement st, ResultSet rs) {
        try{
            if(rs != null){
                rs.close();
            }
            if(st != null){
                st.close();
            }
            if(conn != null){
                conn.close();
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
    }
}
